import { connect } from "umi";
import {
  QueryFilter,
  ProFormText,
  ProFormSelect,
  ProFormDateRangePicker,
} from "@ant-design/pro-components";
const FilterForm = (props: any) => {
  const { dispatch } = props;
  const searchForm = (params: any) => {
    //日期查询格式
    // if (params?.create) {
    //   const { create } = params;
    //   const [startTime, endTime] = create;
    //   Object.assign(params, {
    //     startTime,
    //     endTime,
    //   });
    //   delete params.create;
    // }
    return dispatch({
      type: "SystemDictionary/queryTableDataList",
      params,
    });
  };
  return (
    <QueryFilter<{
      name: string;
      company: string;
    }>
      style={{
        backgroundColor: "#fff",
        margin: "20px 0 30px",
        padding: "20px",
      }}
      defaultCollapsed={false}
      onFinish={searchForm}
      onReset={() => searchForm(undefined)}
    >
      <ProFormText
        name="dictName"
        label="字典名称"
        placeholder={"请输入字典名称"}
        rules={[{ max: 20 }]}
      />
      <ProFormText
        name="dictType"
        label="字典类型"
        placeholder={"请输入字典类型"}
        rules={[{ max: 20 }]}
      />
      <ProFormSelect
        name="status"
        label="字典状态"
        placeholder={"请选择字典状态"}
        showSearch
        valueEnum={{
          0: "正常",
          1: "停用",
        }}
      />
      {/* <ProFormDateRangePicker
        name="create"
        label="创建时间"
        colSize={1}
        placeholder={['开始时间', '结束时间']}
      /> */}
    </QueryFilter>
  );
};

export default connect(({ SystemDictionary }: any) => ({
  ...SystemDictionary,
}))(FilterForm);
